<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Global对象</title>
    </head>
    <body>
        <!--
        Global对象：全局对象
           1.特点:全局对象,这个Global中封装的方法不需要读写就可以直接调用
           2.方法:
               encodeURI():url编码
               decodeURI():url解码
               encodeURIComponent():url编码,编码的字符更多
               decodeURIComponent():url解码

               parseInt():将字符串转为数字
                          逐一判断每一个字符串是是数字,直到不是数字为止,将前边数字返回,或者返回NaN
                          比如:"123ba"->123
                              "z245ni"->NaN

                isNaN(): 判断一个值是否是NaN
                         因为 NaN参与的==比较的结果全部都是false,六亲不认,自己也不认
                 eval(): 将JavaScript字符串作为脚本代码来执行

           3.URL编码
             传智播客=%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2
        -->
        <script>
            /* var str="传智播客";
             var encode=encodeURI(str);
             document.write(encode+"<br>")//%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2
             var s=decodeURI(encode);
             document.write(s+"<br>");//传智播客

             var str1="传智播客";
            var encoder1= encodeURIComponent(str1);
            document.write(encoder1)//%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2
             var s1 = decodeURIComponent(encoder1);
            document.write(s1);//传智播客*/

            var str3 = "http://www.baidu.com?wd=传智播客";
            var encode3 = encodeURI(str3);
            document.write(encode3 + "<br>")//http://www.baidu.com?wd=%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2
            var s3 = decodeURI(encode3);
            document.write(s3 + "<br>");//http://www.baidu.com?wd=传智播客

            var str4 = "http://www.baidu.com?wd=传智播客";
            var encoder4 = encodeURIComponent(str4);
            document.write(encoder4 + "<br>")//http%3A%2F%2Fwww.baidu.com%3Fwd%3D%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2
            var s4 = decodeURIComponent(encoder4);
            document.write(s4);//http://www.baidu.com?wd=传智播客

             var str="234ba";
             var number=parseInt(str);
             alert(number);//234
             alert(typeof number)//number

            var str1="ab234ba";
            var number1=parseInt(str1);
            alert(number1);//NaN
            alert(typeof number1)//number

            var str2=NaN;
            document.write(str1 == NaN);//false
            document.write(number == NaN);//false
            document.write(str2 == NaN);//false

            document.write(isNaN(str1));//true
            document.write(isNaN(number));//false
            document.write(isNaN(str2));//true

            var jscode = "alert(123)";
            alert(jscode);//alert(123)
            eval(jscode);//123


        </script>


    </body>
</html>